package com.example.demo001.exception;

import lombok.Data;

import java.util.Objects;

/**
 * 业务异常
 */

@Data
public class BaseException extends RuntimeException {
    private Integer code;
    private String msg;
    private Long data;

    public BaseException() {
    }

    public BaseException(String msg) {
        super(msg);
    }
    public BaseException(Integer code,String msg){
        this.msg = msg;
        this.code = code;
    }
    public BaseException(Integer code,String msg, Long data){
        this.msg = msg;
        this.code = code;
        this.data = data;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;

        BaseException that = (BaseException) o;

        if (!Objects.equals(code, that.code)) return false;
        return Objects.equals(msg, that.msg);
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (code != null ? code.hashCode() : 0);
        result = 31 * result + (msg != null ? msg.hashCode() : 0);
        return result;
    }





}
